/*
	PROG: feedtime
	LANG: C++
	ID: luiza1
*/

#include <stdio.h>
using namespace std;

char field[755][755];
int w, h;
int cases;
int eat;
int maxEat;

int d[][2] = {{0,1}, {1,0}, {1, 1}, {-1, 1},
		{0, -1}, {-1, 0}, {-1, -1}, {1, -1}};

void dsf(int i, int j) {
//	printf("%d %d\n", i, j);
	
	field[i][j]='V';
	eat++;

//	printf("%d\n", eat);

	if (eat>maxEat) maxEat=eat;

	for (int k=0; k<8; k++) {
		int newI= i+d[k][0], newJ = j+d[k][1];

		if (newI>=0 && newI<h && newJ>=0 && newJ<w)
			if (field[newI][newJ]=='.')
				dsf(newI, newJ);
	}
}

int main() {
	freopen("feedtime.in", "r", stdin);
	freopen("feedtime.out", "w", stdout);

//	scanf("%d", &cases);

//	while (cases--) {
		scanf("%d %d", &w, &h);

		for (int i=0; i<h; i++)
			for (int j=0; j<w; j++)
				scanf(" %c", &field[i][j]); 	

		maxEat=-1;
		
/*		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++)
				printf("%c", field[i][j]);

			printf("\n");
		} */

		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++) {
				eat=0;

				if (field[i][j]=='.')
					dsf(i, j);
			}
		}

		printf("%d\n", maxEat);
//	}

	return 0;
}
